import type { AddressItem, AddressParams } from '@/types/address'
import { request } from '@/utils/request'

/**
 * 添加地址
 */
export const AddAddressAPI = (params: AddressParams) => {
  return request('/member/address', 'POST', params)
}

/**
 * 获取收货地址列表
 */
export const getMemberAddressAPI = () => {
  return request<AddressItem[]>('/member/address', 'GET')
}

/**
 * 获取收货地址详情
 * @param id 地址id(路径参数)
 */
export const getMemberAddressDetailAPI = (id: string) => {
  return request<AddressItem>(`/member/address/${id}`, 'GET')
}

/**
 * 修改收货地址
 * @param id 地址id(路径参数)
 * @param data 表单数据(请求体参数)
 */
export const putMemberAddressByIdAPI = (id: string, params: AddressParams) => {
  return request(`/member/address/${id}`, 'PUT', params)
}

/**
 * 删除收货地址
 * @param id 地址id(路径参数)
 */
export const deleteMemberAddressByIdAPI = (id: string) => {
  return request(`/member/address/${id}`, 'DELETE')
}
